import { api } from "@/api";

export function useOrderItem() {
  async function addOrderItem(parms: any) {
    const res = (
      await api.post(`/orderitems`, {
        ...parms,
      })
    ).data;
    return res?.msg;
  }

  async function editOrderItem(parms: any) {
    const res = (
      await api.patch(`/orderitems`, {
        ...parms,
      })
    ).data;
    return res?.msg;
  }

  async function removeOrderItemByID(id: number) {
    const res = (await api.delete(`/orderitems/${id}`)).data;
    return res?.msg;
  }

  return {
    addOrderItem,
    editOrderItem,
    removeOrderItemByID,
  };
}
